﻿#ifndef RESPONESUTILS_H
#define RESPONESUTILS_H

#include "httpresponse.h"

#include <QJsonArray>
using namespace stefanfrings;

class ResponesUtils
{
public:
    ResponesUtils();
    ~ResponesUtils();

    static void useResponseSuccess(HttpResponse &response,QJsonObject data);

    static void useResponseSuccess(HttpResponse &response,QJsonArray data);

    static void useResponseSuccess(HttpResponse &response,QJsonValue data);

    static void usePageResponseSuccess(HttpResponse &response, uint64_t total, QJsonArray list);

    static void useResponseError(HttpResponse &response,QString message,QJsonValue error);
    /**
     * @brief 参数错误
     * @param response
     * @param message
     */
    static void paramErrorResponse(HttpResponse &response,QString message);
    /**
     * @brief 禁止的
     * @param response
     * @param message
     */
    static void forbiddenResponse(HttpResponse &response,QString message = "Forbidden Exception");
    /**
     * @brief 未授权的动作，权限校验失败
     * @param response
     */
    static void unAuthorizedResponse(HttpResponse &response);
};



#endif // RESPONESUTILS_H
